<template>
  <div class="not-found">
    <div class="not-found__container">
      <SvgIcon icon-class="404" popper-class="error-icon" />
      <div class="not-found__right">
        <div>
          <h1>404</h1>
          <h2>UH OH! 页面丢失</h2>
          <p>
            您所访问的页面出错啦！<a
              class="reload"
              href="javascript:void(0)"
              @click="goBack"
              >重新加载</a
            >
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "404",
  beforeMount() {
    // 将页面url改为/404
    history.replaceState({ pageName: "404" }, "", "/404");
  },
  methods: {
    /* 点击返回上一页 */
    goBack(): void {
      this.$router.go(-1);
    },
  },
});
</script>

<style lang="scss" scoped>
.not-found {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  display: flex;
  align-items: center;
  min-height: 400px;

  &__container {
    min-width: 900px;
    display: flex;
    justify-content: center;
    margin: 0 auto;

    .error-icon {
      @include setWidHei(400px, 400px);
    }

    h1 {
      font: {
        size: 7.5em;
        weight: bold;
      }
      margin: 0;
    }

    h2 {
      font: {
        size: 2rem;
        weight: 500;
      }
      margin: 20px 0 0;
    }
  }

  &__right {
    display: flex;
    align-items: center;
    @include setWidHei(300px, 400px);
  }
}
.reload {
  text-decoration: none;
  padding-bottom: 2px;

  &:hover {
    border-bottom: 1.5px solid #f53e3e;
    color: #f53e3e;
  }
}
</style>
